#ifndef LIGHTWIDGET_H
#define LIGHTWIDGET_H

#include <QWidget>
#include <QPainter>

class LightWidget : public QWidget
{
    Q_OBJECT
public:
    explicit LightWidget(QWidget *parent = 0);
    
signals:
    
public slots:
    void setState(int value);
    void setStandard(int good, int bad);

protected:
    virtual void paintEvent(QPaintEvent *)
     {
         QPainter painter(this);
         painter.setRenderHint(QPainter::Antialiasing);
         if (this->m_value < 0){
             m_color = Qt::gray;
         }else if(this->m_value <= this->m_good){
             m_color = Qt::green;
         }else if(this->m_value <= this->m_bad){
             m_color = Qt::yellow;
         }else{
             m_color = Qt::red;
         }
         painter.setBrush(m_color);
         painter.drawEllipse(0, 0, width(), height());
     }
private:
    QColor m_color;
    int m_good;
    int m_bad;
    int m_value;
};

#endif // LIGHTWIDGET_H
